<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>系统管理后台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8" />
    <link href="${pageContext.request.contextPath}/static/admin/assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/admin/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/css/vendor/animate/animate.min.css">
    <link type="text/css" rel="stylesheet" media="all" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/mmenu/css/jquery.mmenu.all.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/videobackground/css/jquery.videobackground.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/css/vendor/bootstrap-checkbox.css">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/rickshaw/css/rickshaw.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/morris/css/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/tabdrop/css/tabdrop.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/summernote/css/summernote.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/summernote/css/summernote-bs3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/chosen/css/chosen.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/admin/assets/js/vendor/chosen/css/chosen-bootstrap.css">

    <link href="${pageContext.request.contextPath}/static/admin/assets/css/minimal.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/admin/css/company.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/admin/css/sweetalert.css" rel="stylesheet">

    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>

</head>
<body class="bg-1">



<!-- Preloader -->
<div class="mask"><div id="loader"></div></div>
<!--/Preloader -->

<!-- Wrap all page content here -->
<div id="wrap">




    <!-- Make page fluid -->
    <div class="row">





        <!-- Fixed navbar -->
        <div class="navbar navbar-default navbar-fixed-top navbar-transparent-black mm-fixed-top" role="navigation" id="navbar">



            <!-- Branding -->
            <div class="navbar-header col-md-2">
                <a class="navbar-brand" href="index.html">
                    <strong>Shakes</strong>Beare
                </a>
                <div class="sidebar-collapse">
                    <a href="#">
                        <i class="fa fa-bars" style="line-height: 45px"></i>
                    </a>
                </div>
            </div>
            <!-- .nav-collapse -->
            <div class="navbar-collapse">
                <!-- Quick Actions -->
                <ul class="nav navbar-nav quick-actions">
                    <li class="dropdown divided">

                        <a class="dropdown-toggle button" data-toggle="dropdown" href="#">
                            <i class="fa fa-envelope"></i>
                            <span class="label label-transparent-black">1</span>
                        </a>

                        <ul class="dropdown-menu wider arrow nopadding messages">
                            <li><h1>You have <strong>1</strong> new message</h1></li>
                            <li>
                                <a class="cyan" href="#">
                                    <div class="profile-photo">
                                        <img src="${pageContext.request.contextPath}/static/admin/assets/images/ici-avatar.jpg" alt />
                                    </div>
                                    <div class="message-info">
                                        <span class="sender">Ing. Imrich Kamarel</span>
                                        <span class="time">12 mins</span>
                                        <div class="message-content">Duis aute irure dolor in reprehenderit in voluptate velit esse cillum</div>
                                    </div>
                                </a>
                            </li>

                            <li>
                                <a class="green" href="#">
                                    <div class="profile-photo">
                                        <img src="${pageContext.request.contextPath}/static/admin/assets/images/arnold-avatar.jpg" alt />
                                    </div>
                                    <div class="message-info">
                                        <span class="sender">Arnold Karlsberg</span>
                                        <span class="time">1 hour</span>
                                        <div class="message-content">Lorem ipsum dolor sit amet, consectetur adipisicing elit</div>
                                    </div>
                                </a>
                            </li>

                            <li>
                                <a href="#">
                                    <div class="profile-photo">
                                        <img src="${pageContext.request.contextPath}/static/admin/assets/images/face.jpeg" alt />
                                    </div>
                                    <div class="message-info">
                                        <span class="sender">John Douey</span>
                                        <span class="time">3 hours</span>
                                        <div class="message-content">Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia</div>
                                    </div>
                                </a>
                            </li>

                            <li>
                                <a class="red" href="#">
                                    <div class="profile-photo">
                                        <img src="${pageContext.request.contextPath}/static/admin/assets/images/peter-avatar.jpg" alt />
                                    </div>
                                    <div class="message-info">
                                        <span class="sender">Peter Kay</span>
                                        <span class="time">5 hours</span>
                                        <div class="message-content">Ut enim ad minim veniam, quis nostrud exercitation</div>
                                    </div>
                                </a>
                            </li>

                            <li>
                                <a class="orange" href="#">
                                    <div class="profile-photo">
                                        <img src="${pageContext.request.contextPath}/static/admin/assets/images/george-avatar.jpg" alt />
                                    </div>
                                    <div class="message-info">
                                        <span class="sender">George McCain</span>
                                        <span class="time">6 hours</span>
                                        <div class="message-content">Lorem ipsum dolor sit amet, consectetur adipisicing elit</div>
                                    </div>
                                </a>
                            </li>


                            <li class="topborder"><a href="#">Check all messages <i class="fa fa-angle-right"></i></a></li>
                        </ul>

                    </li>
                    <li class="dropdown divided user" id="current-user">
                        <div class="profile-photo">
                            <img src="${pageContext.request.contextPath}/static/admin/assets/images/face.jpeg" alt />
                        </div>
                        <a class="dropdown-toggle options" data-toggle="dropdown" href="#">
                            管理员 <i class="fa fa-caret-down"></i>
                        </a>

                        <ul class="dropdown-menu arrow settings">

                            <li>

                                <h3>Backgrounds:</h3>
                                <ul id="color-schemes">
                                    <li><a href="#" class="bg-1"></a></li>
                                    <li><a href="#" class="bg-2"></a></li>
                                    <li><a href="#" class="bg-3"></a></li>
                                    <li><a href="#" class="bg-4"></a></li>
                                    <li><a href="#" class="bg-5"></a></li>
                                    <li><a href="#" class="bg-6"></a></li>
                                </ul>

                                <div class="form-group videobg-check">
                                    <div class="col-xs-4 control-label">
                                        <div class="onoffswitch greensea small">
                                            <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="videobg-check">
                                        </div>
                                    </div>
                                </div>

                            </li>
                            <li class="divider"></li>
                            <li>
                                <a href="#"><i class="fa fa-user"></i>修改密码</a>
                            </li>
                            <li>
                                <a href="${pageContext.request.contextPath }/admin/logout.action"><i class="fa fa-power-off"></i> Logout</a>
                            </li>
                            <li></li>

                        </ul>
                    </li>


                </ul>
                <!-- /Quick Actions -->



                <!-- Sidebar -->
                <ul class="nav navbar-nav side-nav" id="sidebar">

                    <li class="collapsed-content">
                        <ul>
                            <li class="search"><!-- Collapsed search pasting here at 768px --></li>
                        </ul>
                    </li>

                    <li class="navigation" id="navigation">
                        <a href="#" class="sidebar-toggle" data-toggle="#navigation">Navigation <i class="fa fa-angle-up"></i></a>

                        <ul class="menu">

                            <li>
                                <a href="${pageContext.request.contextPath }/admin/index/index.action">
                                    <i class="fa fa-tachometer"></i> 概况
                                    <span class="badge badge-red"></span>
                                </a>
                            </li>
                            <li class="active">
                                <a href="${pageContext.request.contextPath}/admin/ad/index.action">
                                    <i class="fa fa-tint"></i> 广告管理
                                </a>
                            </li>
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-th-large"></i> 用户管理 <b class="fa fa-plus dropdown-plus"></b>
                                </a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="${pageContext.request.contextPath}/admin/customer/index.action">
                                            <i class="fa fa-caret-right"></i> 用户管理
                                        </a>
                                    </li>
                                    <li>
                                        <a href="${pageContext.request.contextPath}/admin/customer/resumeIndex.action">
                                            <i class="fa fa-caret-right"></i> 简历管理
                                        </a>
                                    </li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-th-large"></i> 企业管理 <b class="fa fa-plus dropdown-plus"></b>
                                </a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="${pageContext.request.contextPath }/admin/company/index.action">
                                            <i class="fa fa-caret-right"></i> 已认证企业
                                        </a>
                                    </li>
                                    <li>
                                        <a href="${pageContext.request.contextPath }/admin/company/verify.action">
                                            <i class="fa fa-caret-right"></i> 待审核企业
                                        </a>
                                    </li>
                                </ul>
                            </li>

                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                                    <i class="fa fa-child"></i> 职位管理 <b class="fa fa-plus dropdown-plus"></b>
                                </a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="${pageContext.request.contextPath }/admin/job/index.action">
                                            <i class="fa fa-caret-right"></i> 职位列表
                                        </a>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                </ul>
                <!-- Sidebar end -->





            </div>
            <!--/.nav-collapse -->





        </div>
        <!-- Fixed navbar end -->






        <!-- Page content -->
        <div id="content" class="col-md-12">









            <!-- page header -->
            <div class="pageheader">
                <h2><i class="fa fa-tint"></i> 新增广告信息
                </h2>
            </div>
            <!-- /page header -->






            <!-- content main container -->

            <div class="main">
                <!--具体功能框架写在这里-->
                <div class="row">
                    <div class="col-md-12 col-sm-12">
                        <section class="tile color transparent-white">
                            <div class="tile-header">
                                <h1>
                                    <strong>填写广告信息</strong>
                                </h1>
                            </div>
                            <div class="tile-body">
                                <div class="form-horizontal" role="form">

                                    <div class="form-group">
                                        <label for="company_name" class="col-md-3 control-label">公司名称</label>
                                        <div class="col-md-6">
                                            <input type="text" class="form-control" id="company_name" placeholder="请输入公司名称">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-md-3 control-label">广告图片</label>
                                        <div class="col-md-6">
                                            <div class="input-group">
                                              <span class="input-group-btn">
                                                <span class="btn btn-primary btn-file">
                                                    <i class="fa fa-upload"></i><input type="file" id="input01" name="input01" onchange="readFile(this)">
                                                </span>
                                              </span>
                                                <input type="text" class="form-control" readonly placeholder="请选择 JPG/PNG/GIF 类型的图片">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-md-3"></label>
                                        <div class="col-md-6">
                                            <img src="" style="width:100%;min-height:150px" alt="暂无图片" id="imgurl">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="ad_desc" class="col-md-3 control-label">广告描述</label>
                                        <div class="col-md-6">
                                            <input type="text" class="form-control" id="ad_desc" placeholder="请输入广告描述">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="ad_url" class="col-md-3 control-label">广告链接</label>
                                        <div class="col-md-6">
                                            <input type="text" class="form-control" id="ad_url" placeholder="请输入广告链接">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-md-3 control-label">状态</label>
                                        <div class="col-md-6">
                                            <div class="radio radio-transparent">
                                                <input type="radio" name="status" id="optionsRadios1" value="1" checked>
                                                <label for="optionsRadios1">使用</label>
                                            </div>
                                            <div class="radio radio-transparent">
                                                <input type="radio" name="status" id="optionsRadios2" value="0">
                                                <label for="optionsRadios2">停用</label>
                                            </div>
                                        </div>

                                </div>
                                    </div>
                            </div>
                            <div class="tile-footer">
                                <div class="row">
                                    <div class="col-md-12" style="text-align: center">
                                        <a class="btn btn-primary" href="javascript:insertAd()">提交</a>
                                        <button type="reset" class="btn btn-default">重置</button>
                                        <button type="button" class="btn btn-orange"><a href="${pageContext.request.contextPath}/admin/ad/index.action" style="color: white">返回</a></button>
                                    </div>
                                </div>
                            </div>
                        </section>
                    </div>
            </div>
            </div>
            <!-- /content container -->

        </div>
        <!-- Page content end -->


    </div>
    <!-- Make page fluid-->




</div>
<!-- Wrap all page content end -->



<section class="videocontent" id="video"></section>



<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="${pageContext.request.contextPath}/static/admin/assets/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/mmenu/js/jquery.mmenu.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/sparkline/jquery.sparkline.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/nicescroll/jquery.nicescroll.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/animate-numbers/jquery.animateNumbers.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/videobackground/jquery.videobackground.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/blockui/jquery.blockUI.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/rickshaw/raphael-min.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/rickshaw/d3.v2.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/rickshaw/rickshaw.min.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/morris/morris.min.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/tabdrop/bootstrap-tabdrop.min.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/summernote/summernote.min.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/chosen/chosen.jquery.min.js"></script>

<script src="${pageContext.request.contextPath}/static/admin/assets/js/minimal.min.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/js/page.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/js/sweetalert.min.js"></script>
<script src="${pageContext.request.contextPath}/static/admin/js/ajaxupload.js"></script>



<script>

    function readFile(obj){
        var file = obj.files[0];
        //判断类型是不是图片
        if(!/image\/\w+/.test(file.type)){
            alert("请确保文件为图像类型");
            return false;
        }
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#imgurl').attr('src',this.result);

        }
    }
</script>

<script>
    function insertAd(){
        var company_name = $('#company_name').val();
        var ad_desc = $('#ad_desc').val();
        var ad_url = $('#ad_url').val();
        var status = $('input:radio[name=status]:checked').val();
        if(company_name==""||ad_desc=="" ||ad_url=="" || status==""){
            swal("","请填写完整广告信息！","error");
            return;
        }
        $.ajaxFileUpload({
            url:'${pageContext.request.contextPath}/admin/ad/insertAd.action',
            secureuri : false, //一般设置为false
            fileElementId : 'input01', //文件上传空间的id属性  <input type="file" id="file" name="file" />
            type : 'post',
            dataType : 'json',
            data : {
                company_name : company_name,
                ad_desc : ad_desc,
                ad_url : ad_url,
                status : status
            },
            success:function(data, status){
                if(data == -1){
                    swal("","请填写完整用户信息！","error");
                }
                if(data == 1){
                    swal("","保存成功！","success");
                }else{
                    swal("","服务器出错！","error");
                }
            },

            error:function(data, status, e)//服务器响应失败处理函数
            {
                swal("","服务器出错！","error");
                // alert(data.msg);
            }
        });

        return false;
    }
</script>
</body>
</html>


